package com.five.taotao.guide_mine;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.five.taotao.Adapter.VPFregmentAdapter;
import com.five.taotao.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * gaomengjiao
 * Created by MQ on 2016/11/4.
 */
public class MyCollectActivity extends AppCompatActivity {

    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.edit)
    TextView edit;
    @BindView(R.id.vp)
    ViewPager vp;
    @BindView(R.id.tab)
    TabLayout tab;
    @BindView(R.id.checkbox)
    CheckBox checkbox;
    @BindView(R.id.shanchu)
    Button shanchu;
    @BindView(R.id.bottom)
    LinearLayout bottom;
    private List<Fragment> mData;
    private List<String> list;
    private int flag = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_collect);
        ButterKnife.bind(this);
        initData();
        VPFregmentAdapter adapter = new VPFregmentAdapter(getSupportFragmentManager(), mData, list);
        vp.setAdapter(adapter);
        tab.setupWithViewPager(vp);//两者实现联动
    }

    /**
     * 初始化数据
     */
    private void initData() {
        mData = new ArrayList<>();
        mData.add(new GoodsCollectFragment());
        mData.add(new ShopCollectFragment());

        list = new ArrayList<>();
        list.add("宝贝收藏");
        list.add("店铺收藏");
    }

    @OnClick({R.id.back, R.id.edit, R.id.shanchu, R.id.checkbox})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.edit:
                if(flag==1){
                    bottom.setVisibility(View.VISIBLE);
                    edit.setText("完成");
                    flag=0;
                }else{
                    bottom.setVisibility(View.GONE);
                    edit.setText("编辑");
                    checkbox.setChecked(false);
                    flag=1;
                }
                break;
            case R.id.shanchu:

                break;
            case R.id.checkbox:
                if (checkbox.isChecked()){
                    checkbox.setText("取消全选");
                }
                break;
        }
    }
}
